<?php
$com = App::getModel('system/component')
        ->setCode('Menu')
        ->setName('menu.component_name')
        ->setAuthor('Coder Soul Studio')
        ->setWebsite('www.codersoul.com')
        ->setEmail('codersoulstudio@gmail.com')
        ->setVersion('0.1')
        ->save();
$menu = App::getModel('system/menu')
        ->setName('menu.menu_manage')
        ->setUrl('')
        ->setComponentId($com->getId())
        ->save();
App::getModel('system/menu')
        ->setName('menu.menu_index')
        ->setUrl('/menu/menu/index')
        ->setComponentId($com->getId())
        ->setParentId($menu->getId())
        ->save();

$db = $GLOBALS[RC]->getDb();
$sql = "
SET FOREIGN_KEY_CHECKS=0;

DROP TABLE IF EXISTS `menu_category`;

CREATE TABLE `menu_category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `component_id` int(11) NOT NULL,
  `code` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

DROP TABLE IF EXISTS `menu_information`;

CREATE TABLE `menu_information` (
  `id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `parent_id` int(11) NOT NULL,
  `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `url` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `target` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `level` tinyint(2) DEFAULT NULL,
  `id_path` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL,
  `argument` text COLLATE utf8_unicode_ci,
  `status` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_time` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$db->executeBatch($sql);